3.10 \(\int \frac{\cos ^2(x)}{a+b \sin (x)+c \sin ^2(x)} \, dx\)

Optimal. Leaf size=230 \[ -\frac{\sqrt{2} \sqrt{-b \sqrt{b^2-4 a c}-2 c (a+c)+b^2} \tan ^{-1}\left (\frac{\tan \left (\frac{x}{2}\right ) \left (b-\sqrt{b^2-4 a c}\right )+2 c}{\sqrt{2} \sqrt{-b \sqrt{b^2-4 a c}-2 c (a+c)+b^2}}\right )}{c \sqrt{b^2-4 a c}}+\frac{\sqrt{2} \sqrt{b \sqrt{b^2-4 a c}-2 c (a+c)+b^2} \tan ^{-1}\left (\frac{\tan \left (\frac{x}{2}\right ) \left (\sqrt{b^2-4 a c}+b\right )+2 c}{\sqrt{2} \sqrt{b \sqrt{b^2-4 a c}-2 c (a+c)+b^2}}\right )}{c \sqrt{b^2-4 a c}}-\frac{x}{c} \]

[Out]

-(x/c) - (Sqrt[2]*Sqrt[b^2 - 2*c*(a + c) - b*Sqrt[b^2 - 4*a*c]]*ArcTan[(2*c + (b - Sqrt[b^2 - 4*a*c])*Tan[x/2]
)/(Sqrt[2]*Sqrt[b^2 - 2*c*(a + c) - b*Sqrt[b^2 - 4*a*c]])])/(c*Sqrt[b^2 - 4*a*c]) + (Sqrt[2]*Sqrt[b^2 - 2*c*(a
 + c) + b*Sqrt[b^2 - 4*a*c]]*ArcTan[(2*c + (b + Sqrt[b^2 - 4*a*c])*Tan[x/2])/(Sqrt[2]*Sqrt[b^2 - 2*c*(a + c) +
 b*Sqrt[b^2 - 4*a*c]])])/(c*Sqrt[b^2 - 4*a*c])

________________________________________________________________________________________

Rubi [A]  time = 0.585144, antiderivative size = 230, normalized size of antiderivative = 1., number of steps used = 9, number of rules used = 5, integrand size = 19, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.263, Rules used = {3266, 3292, 2660, 618, 204} \[ -\frac{\sqrt{2} \sqrt{-b \sqrt{b^2-4 a c}-2 c (a+c)+b^2} \tan ^{-1}\left (\frac{\tan \left (\frac{x}{2}\right ) \left (b-\sqrt{b^2-4 a c}\right )+2 c}{\sqrt{2} \sqrt{-b \sqrt{b^2-4 a c}-2 c (a+c)+b^2}}\right )}{c \sqrt{b^2-4 a c}}+\frac{\sqrt{2} \sqrt{b \sqrt{b^2-4 a c}-2 c (a+c)+b^2} \tan ^{-1}\left (\frac{\tan \left (\frac{x}{2}\right ) \left (\sqrt{b^2-4 a c}+b\right )+2 c}{\sqrt{2} \sqrt{b \sqrt{b^2-4 a c}-2 c (a+c)+b^2}}\right )}{c \sqrt{b^2-4 a c}}-\frac{x}{c} \]

Antiderivative was successfully verified.

[In]

Int[Cos[x]^2/(a + b*Sin[x] + c*Sin[x]^2),x]

[Out]

-(x/c) - (Sqrt[2]*Sqrt[b^2 - 2*c*(a + c) - b*Sqrt[b^2 - 4*a*c]]*ArcTan[(2*c + (b - Sqrt[b^2 - 4*a*c])*Tan[x/2]
)/(Sqrt[2]*Sqrt[b^2 - 2*c*(a + c) - b*Sqrt[b^2 - 4*a*c]])])/(c*Sqrt[b^2 - 4*a*c]) + (Sqrt[2]*Sqrt[b^2 - 2*c*(a
 + c) + b*Sqrt[b^2 - 4*a*c]]*ArcTan[(2*c + (b + Sqrt[b^2 - 4*a*c])*Tan[x/2])/(Sqrt[2]*Sqrt[b^2 - 2*c*(a + c) +
 b*Sqrt[b^2 - 4*a*c]])])/(c*Sqrt[b^2 - 4*a*c])

Rule 3266

Int[cos[(d_.) + (e_.)*(x_)]^(m_.)*((a_.) + (b_.)*sin[(d_.) + (e_.)*(x_)]^(n_.) + (c_.)*sin[(d_.) + (e_.)*(x_)]
^(n2_.))^(p_.), x_Symbol] :> Int[ExpandTrig[(1 - sin[d + e*x]^2)^(m/2)*(a + b*sin[d + e*x]^n + c*sin[d + e*x]^
(2*n))^p, x], x] /; FreeQ[{a, b, c, d, e}, x] && EqQ[n2, 2*n] && IntegerQ[m/2] && NeQ[b^2 - 4*a*c, 0] && Integ
ersQ[n, p]

Rule 3292

Int[((A_) + (B_.)*sin[(d_.) + (e_.)*(x_)])/((a_.) + (b_.)*sin[(d_.) + (e_.)*(x_)] + (c_.)*sin[(d_.) + (e_.)*(x
_)]^2), x_Symbol] :> Module[{q = Rt[b^2 - 4*a*c, 2]}, Dist[B + (b*B - 2*A*c)/q, Int[1/(b + q + 2*c*Sin[d + e*x
]), x], x] + Dist[B - (b*B - 2*A*c)/q, Int[1/(b - q + 2*c*Sin[d + e*x]), x], x]] /; FreeQ[{a, b, c, d, e, A, B
}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 2660

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x]}, Dis
t[(2*e)/d, Subst[Int[1/(a + 2*b*e*x + a*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] &&
 NeQ[a^2 - b^2, 0]

Rule 618

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 204

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> -Simp[ArcTan[(Rt[-b, 2]*x)/Rt[-a, 2]]/(Rt[-a, 2]*Rt[-b, 2]), x] /
; FreeQ[{a, b}, x] && PosQ[a/b] && (LtQ[a, 0] || LtQ[b, 0])

Rubi steps

\begin{align*} \int \frac{\cos ^2(x)}{a+b \sin (x)+c \sin ^2(x)} \, dx &=\int \left (-\frac{1}{c}+\frac{a \left (1+\frac{c}{a}\right )+b \sin (x)}{c \left (a+b \sin (x)+c \sin ^2(x)\right )}\right ) \, dx\\ &=-\frac{x}{c}+\frac{\int \frac{a \left (1+\frac{c}{a}\right )+b \sin (x)}{a+b \sin (x)+c \sin ^2(x)} \, dx}{c}\\ &=-\frac{x}{c}+\frac{\left (b-\frac{b^2-2 c (a+c)}{\sqrt{b^2-4 a c}}\right ) \int \frac{1}{b-\sqrt{b^2-4 a c}+2 c \sin (x)} \, dx}{c}+\frac{\left (b+\frac{b^2-2 c (a+c)}{\sqrt{b^2-4 a c}}\right ) \int \frac{1}{b+\sqrt{b^2-4 a c}+2 c \sin (x)} \, dx}{c}\\ &=-\frac{x}{c}+\frac{\left (2 \left (b-\frac{b^2-2 c (a+c)}{\sqrt{b^2-4 a c}}\right )\right ) \operatorname{Subst}\left (\int \frac{1}{b-\sqrt{b^2-4 a c}+4 c x+\left (b-\sqrt{b^2-4 a c}\right ) x^2} \, dx,x,\tan \left (\frac{x}{2}\right )\right )}{c}+\frac{\left (2 \left (b+\frac{b^2-2 c (a+c)}{\sqrt{b^2-4 a c}}\right )\right ) \operatorname{Subst}\left (\int \frac{1}{b+\sqrt{b^2-4 a c}+4 c x+\left (b+\sqrt{b^2-4 a c}\right ) x^2} \, dx,x,\tan \left (\frac{x}{2}\right )\right )}{c}\\ &=-\frac{x}{c}-\frac{\left (4 \left (b-\frac{b^2-2 c (a+c)}{\sqrt{b^2-4 a c}}\right )\right ) \operatorname{Subst}\left (\int \frac{1}{-8 \left (b^2-2 c (a+c)-b \sqrt{b^2-4 a c}\right )-x^2} \, dx,x,4 c+2 \left (b-\sqrt{b^2-4 a c}\right ) \tan \left (\frac{x}{2}\right )\right )}{c}-\frac{\left (4 \left (b+\frac{b^2-2 c (a+c)}{\sqrt{b^2-4 a c}}\right )\right ) \operatorname{Subst}\left (\int \frac{1}{4 \left (4 c^2-\left (b+\sqrt{b^2-4 a c}\right )^2\right )-x^2} \, dx,x,4 c+2 \left (b+\sqrt{b^2-4 a c}\right ) \tan \left (\frac{x}{2}\right )\right )}{c}\\ &=-\frac{x}{c}-\frac{\sqrt{2} \sqrt{b^2-2 c (a+c)-b \sqrt{b^2-4 a c}} \tan ^{-1}\left (\frac{2 c+\left (b-\sqrt{b^2-4 a c}\right ) \tan \left (\frac{x}{2}\right )}{\sqrt{2} \sqrt{b^2-2 c (a+c)-b \sqrt{b^2-4 a c}}}\right )}{c \sqrt{b^2-4 a c}}+\frac{\sqrt{2} \sqrt{b^2-2 c (a+c)+b \sqrt{b^2-4 a c}} \tan ^{-1}\left (\frac{2 c+\left (b+\sqrt{b^2-4 a c}\right ) \tan \left (\frac{x}{2}\right )}{\sqrt{2} \sqrt{b^2-2 c (a+c)+b \sqrt{b^2-4 a c}}}\right )}{c \sqrt{b^2-4 a c}}\\ \end{align*}

Mathematica [C]  time = 0.458934, size = 314, normalized size = 1.37 \[ \frac{\frac{\left (b \sqrt{4 a c-b^2}-2 i c (a+c)+i b^2\right ) \tan ^{-1}\left (\frac{2 c+\tan \left (\frac{x}{2}\right ) \left (b-i \sqrt{4 a c-b^2}\right )}{\sqrt{2} \sqrt{-i b \sqrt{4 a c-b^2}-2 c (a+c)+b^2}}\right )}{\sqrt{2 a c-\frac{b^2}{2}} \sqrt{-i b \sqrt{4 a c-b^2}-2 c (a+c)+b^2}}+\frac{\left (b \sqrt{4 a c-b^2}+2 i c (a+c)-i b^2\right ) \tan ^{-1}\left (\frac{2 c+\tan \left (\frac{x}{2}\right ) \left (b+i \sqrt{4 a c-b^2}\right )}{\sqrt{2} \sqrt{i b \sqrt{4 a c-b^2}-2 c (a+c)+b^2}}\right )}{\sqrt{2 a c-\frac{b^2}{2}} \sqrt{i b \sqrt{4 a c-b^2}-2 c (a+c)+b^2}}-x}{c} \]

Antiderivative was successfully verified.

[In]

Integrate[Cos[x]^2/(a + b*Sin[x] + c*Sin[x]^2),x]

[Out]

(-x + ((I*b^2 - (2*I)*c*(a + c) + b*Sqrt[-b^2 + 4*a*c])*ArcTan[(2*c + (b - I*Sqrt[-b^2 + 4*a*c])*Tan[x/2])/(Sq
rt[2]*Sqrt[b^2 - 2*c*(a + c) - I*b*Sqrt[-b^2 + 4*a*c]])])/(Sqrt[-b^2/2 + 2*a*c]*Sqrt[b^2 - 2*c*(a + c) - I*b*S
qrt[-b^2 + 4*a*c]]) + (((-I)*b^2 + (2*I)*c*(a + c) + b*Sqrt[-b^2 + 4*a*c])*ArcTan[(2*c + (b + I*Sqrt[-b^2 + 4*
a*c])*Tan[x/2])/(Sqrt[2]*Sqrt[b^2 - 2*c*(a + c) + I*b*Sqrt[-b^2 + 4*a*c]])])/(Sqrt[-b^2/2 + 2*a*c]*Sqrt[b^2 -
2*c*(a + c) + I*b*Sqrt[-b^2 + 4*a*c]]))/c

________________________________________________________________________________________

Maple [B]  time = 0.163, size = 1246, normalized size = 5.4 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(cos(x)^2/(a+b*sin(x)+c*sin(x)^2),x)

[Out]

2*a/c/(4*a*c-b^2)/(4*c*a-2*b^2+2*b*(-4*a*c+b^2)^(1/2)+4*a^2)^(1/2)*arctan((-2*a*tan(1/2*x)+(-4*a*c+b^2)^(1/2)-
b)/(4*c*a-2*b^2+2*b*(-4*a*c+b^2)^(1/2)+4*a^2)^(1/2))*(-4*a*c+b^2)^(1/2)*b-2/(4*a*c-b^2)/(4*c*a-2*b^2+2*b*(-4*a
*c+b^2)^(1/2)+4*a^2)^(1/2)*arctan((-2*a*tan(1/2*x)+(-4*a*c+b^2)^(1/2)-b)/(4*c*a-2*b^2+2*b*(-4*a*c+b^2)^(1/2)+4
*a^2)^(1/2))*b*(-4*a*c+b^2)^(1/2)-8*a^2/(4*a*c-b^2)/(4*c*a-2*b^2+2*b*(-4*a*c+b^2)^(1/2)+4*a^2)^(1/2)*arctan((-
2*a*tan(1/2*x)+(-4*a*c+b^2)^(1/2)-b)/(4*c*a-2*b^2+2*b*(-4*a*c+b^2)^(1/2)+4*a^2)^(1/2))+2*a/c/(4*a*c-b^2)/(4*c*
a-2*b^2+2*b*(-4*a*c+b^2)^(1/2)+4*a^2)^(1/2)*arctan((-2*a*tan(1/2*x)+(-4*a*c+b^2)^(1/2)-b)/(4*c*a-2*b^2+2*b*(-4
*a*c+b^2)^(1/2)+4*a^2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2-2*b*(-4*a*c+b^2)^(1/2
)+4*a^2)^(1/2)*arctan((2*a*tan(1/2*x)+b+(-4*a*c+b^2)^(1/2))/(4*c*a-2*b^2-2*b*(-4*a*c+b^2)^(1/2)+4*a^2)^(1/2))*
c-2/(4*a*c-b^2)/(4*c*a-2*b^2-2*b*(-4*a*c+b^2)^(1/2)+4*a^2)^(1/2)*arctan((2*a*tan(1/2*x)+b+(-4*a*c+b^2)^(1/2))/
(4*c*a-2*b^2-2*b*(-4*a*c+b^2)^(1/2)+4*a^2)^(1/2))*b^2-2/c*arctan(tan(1/2*x))

________________________________________________________________________________________

Maxima [F(-1)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cos(x)^2/(a+b*sin(x)+c*sin(x)^2),x, algorithm="maxima")

[Out]

Timed out

________________________________________________________________________________________

Fricas [B]  time = 2.8538, size = 1983, normalized size = 8.62 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cos(x)^2/(a+b*sin(x)+c*sin(x)^2),x, algorithm="fricas")

[Out]

1/4*(sqrt(2)*c*sqrt(-(b^2 - 2*a*c - 2*c^2 + (b^2*c^2 - 4*a*c^3)*sqrt(b^2/(b^2*c^4 - 4*a*c^5)))/(b^2*c^2 - 4*a*
c^3))*log(sqrt(2)*(b^2*c^3 - 4*a*c^4)*sqrt(b^2/(b^2*c^4 - 4*a*c^5))*sqrt(-(b^2 - 2*a*c - 2*c^2 + (b^2*c^2 - 4*
a*c^3)*sqrt(b^2/(b^2*c^4 - 4*a*c^5)))/(b^2*c^2 - 4*a*c^3))*cos(x) + b^2*sin(x) + (b^2*c^2 - 4*a*c^3)*sqrt(b^2/
(b^2*c^4 - 4*a*c^5))*sin(x) + 2*b*c) - sqrt(2)*c*sqrt(-(b^2 - 2*a*c - 2*c^2 + (b^2*c^2 - 4*a*c^3)*sqrt(b^2/(b^
2*c^4 - 4*a*c^5)))/(b^2*c^2 - 4*a*c^3))*log(sqrt(2)*(b^2*c^3 - 4*a*c^4)*sqrt(b^2/(b^2*c^4 - 4*a*c^5))*sqrt(-(b
^2 - 2*a*c - 2*c^2 + (b^2*c^2 - 4*a*c^3)*sqrt(b^2/(b^2*c^4 - 4*a*c^5)))/(b^2*c^2 - 4*a*c^3))*cos(x) - b^2*sin(
x) - (b^2*c^2 - 4*a*c^3)*sqrt(b^2/(b^2*c^4 - 4*a*c^5))*sin(x) - 2*b*c) - sqrt(2)*c*sqrt(-(b^2 - 2*a*c - 2*c^2
- (b^2*c^2 - 4*a*c^3)*sqrt(b^2/(b^2*c^4 - 4*a*c^5)))/(b^2*c^2 - 4*a*c^3))*log(sqrt(2)*(b^2*c^3 - 4*a*c^4)*sqrt
(b^2/(b^2*c^4 - 4*a*c^5))*sqrt(-(b^2 - 2*a*c - 2*c^2 - (b^2*c^2 - 4*a*c^3)*sqrt(b^2/(b^2*c^4 - 4*a*c^5)))/(b^2
*c^2 - 4*a*c^3))*cos(x) + b^2*sin(x) - (b^2*c^2 - 4*a*c^3)*sqrt(b^2/(b^2*c^4 - 4*a*c^5))*sin(x) + 2*b*c) + sqr
t(2)*c*sqrt(-(b^2 - 2*a*c - 2*c^2 - (b^2*c^2 - 4*a*c^3)*sqrt(b^2/(b^2*c^4 - 4*a*c^5)))/(b^2*c^2 - 4*a*c^3))*lo
g(sqrt(2)*(b^2*c^3 - 4*a*c^4)*sqrt(b^2/(b^2*c^4 - 4*a*c^5))*sqrt(-(b^2 - 2*a*c - 2*c^2 - (b^2*c^2 - 4*a*c^3)*s
qrt(b^2/(b^2*c^4 - 4*a*c^5)))/(b^2*c^2 - 4*a*c^3))*cos(x) - b^2*sin(x) + (b^2*c^2 - 4*a*c^3)*sqrt(b^2/(b^2*c^4
 - 4*a*c^5))*sin(x) - 2*b*c) - 4*x)/c

________________________________________________________________________________________

Sympy [F(-1)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cos(x)**2/(a+b*sin(x)+c*sin(x)**2),x)

[Out]

Timed out

________________________________________________________________________________________

Giac [F]  time = 0., size = 0, normalized size = 0. \begin{align*} \int \frac{\cos \left (x\right )^{2}}{c \sin \left (x\right )^{2} + b \sin \left (x\right ) + a}\,{d x} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cos(x)^2/(a+b*sin(x)+c*sin(x)^2),x, algorithm="giac")

[Out]

integrate(cos(x)^2/(c*sin(x)^2 + b*sin(x) + a), x)